package com.android.yummycookies.loader;

import android.app.Activity;
import android.os.Handler;
import android.widget.FrameLayout;

import com.android.yummycookies.component.loadingScreen.AbstractThemeLoadingScreen;
import com.android.yummycookies.service.storer.imagesStorer.binder.BitmapsStoreBinder;
import com.android.yummycookies.service.storer.imagesStorer.binder.IThemeStoreBinder;
import com.android.yummycookies.util.Constant;
import com.android.yummycookies.util.Event;

public abstract class AbstractThemeLoader<T extends AbstractThemeLoadingScreen> {
	
	public static final int THEME_LOADED = Event.THEME_LOADED;
	public static final int START_LOADING_THEME = Event.START_LOADING_THEME;
	public static final int END_LOADING_THEME = Event.END_LOADING_THEME;
	public static final int THEME_NOT_LOADED = Event.THEME_NOT_LOADED;

	private final Activity activity;

	private BitmapsStoreBinder themeStore;

	private Handler serviceObserver;
	private final int destructionEvent;

	private final Handler handlerToNotify;

	private T loadingScreen;

	public AbstractThemeLoader(Activity activity, BitmapsStoreBinder themeStore,
			int destructionEvent, Handler handlerToNotify) {
		this.activity = activity;
		this.themeStore = themeStore;
		this.serviceObserver = createServiceHandler();
		this.destructionEvent = destructionEvent;
		this.handlerToNotify = handlerToNotify;

		this.serviceObserver = createServiceHandler();
	}

	public abstract Handler createServiceHandler();

	public abstract T createLoadingScreen();
	
	public void setLoadingScreen(T loadingScreen) {
		this.loadingScreen = loadingScreen;
	}
	
	public abstract void startLoading();

	public Activity getActivity() {
		return activity;
	}

	public BitmapsStoreBinder getThemeStore() {
		return themeStore;
	}

	public int getDestructionEvent() {
		return destructionEvent;
	}

	public Handler getHandlerToNotify() {
		return handlerToNotify;
	}

	public T getLoadingScreen() {
		return loadingScreen;
	}

	public Handler getHandler() {
		return serviceObserver;
	}

}
